package renda.action.user;

import renda.common.Constants;
import renda.common.SessionUtil;
import renda.dao.serivce.UserService;
import renda.pojo.Users;

public class LoginAction {

	private Users user;

	private UserService userService;

	public String execute() {
		Users user1 = userService.login(user);
		if (user1 != null && user1.getUid() != null) {
			SessionUtil.setAttr("curruser", user1);
			SessionUtil.setAttr(Constants.USER_TYPE, Constants.USER_TYPE_USER);
			return "success";
		}
		SessionUtil.setAttr("userloginerror", "用户名或密码错误");
		return "error";
	}

	public Users getUser() {
		return user;
	}

	public void setUser(Users user) {
		this.user = user;
	}

	public UserService getUserService() {
		return userService;
	}

	public void setUserService(UserService userService) {
		this.userService = userService;
	}
}
